package com.example.backend.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.backend.entity.EmailLog;
import com.example.backend.mapper.EmailLogMapper;
import com.example.backend.service.EmailLogService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * 邮件日志服务实现类
 */
@Service
public class EmailLogServiceImpl extends ServiceImpl<EmailLogMapper, EmailLog> implements EmailLogService {
    
    @Override
    public void recordEmailLog(String to, String subject, String content, String template, 
            boolean success, String errorMsg) {
        EmailLog log = new EmailLog();
        log.setTo(to);
        log.setSubject(subject);
        log.setContent(content);
        log.setTemplate(template);
        log.setStatus(success ? 1 : 0);
        log.setErrorMsg(errorMsg);
        log.setSendTime(LocalDateTime.now());
        save(log);
    }
} 